Skip to content

Change typespec_client_core::http::policies::logging Request and Response log level to debug#3643

Merged
LarryOsterman merged 1 commit intoAzure:mainfrom
jlaundry:fix-typespec-http-logging-level
Apr 8, 2026
Merged

Change typespec_client_core::http::policies::logging Request and Response log level to debug#3643
LarryOsterman merged 1 commit intoAzure:mainfrom
jlaundry:fix-typespec-http-logging-level

Conversation

@jlaundry
Copy link
Copy Markdown
Contributor

When using azure_identity, applications see Request and Response INFO log events as access tokens are refreshed, sometimes hourly(ish):

2026-01-30T23:14:25.004300Z  INFO  typespec_client_core::http::policies::logging: ==> Request: url: https://login.microsoftonline.com/00000000-0000-0000-0000-000000000000/oauth2/v2.0/token, method: POST, headers: { x-ms-client-request-id: 00000000-0000-0000-0000-000000000000 content-type: application/x-www-form-urlencoded user-agent: azsdk-rust-identity/0.30.0 (1.92.0; linux; x86_64)  }
2026-01-30T23:14:25.257778Z  INFO  typespec_client_core::http::policies::logging: <== Response: { url: https://login.microsoftonline.com/00000000-0000-0000-0000-000000000000/oauth2/v2.0/token, status: 200, headers: { date: Fri, 30 Jan 2026 23:14:25 GMT x-ms-srs: REDACTED content-type: application/json; charset=utf-8 x-content-type-options: REDACTED expires: -1 x-ms-ests-server: REDACTED strict-transport-security: REDACTED p3p: REDACTED x-xss-protection: REDACTED content-length: 1712 cache-control: no-store, no-cache set-cookie: REDACTED pragma: no-cache x-ms-request-id: 00000000-0000-0000-0000-000000000000 content-security-policy-report-only: REDACTED  } }
2026-01-31T00:09:29.955171Z  INFO  typespec_client_core::http::policies::logging: ==> Request: url: https://login.microsoftonline.com/00000000-0000-0000-0000-000000000000/oauth2/v2.0/token, method: POST, headers: { user-agent: azsdk-rust-identity/0.30.0 (1.92.0; linux; x86_64) content-type: application/x-www-form-urlencoded x-ms-client-request-id: 00000000-0000-0000-0000-000000000000  }
2026-01-31T00:09:30.196806Z  INFO  typespec_client_core::http::policies::logging: <== Response: { url: https://login.microsoftonline.com/00000000-0000-0000-0000-000000000000/oauth2/v2.0/token, status: 200, headers: { x-ms-request-id: 00000000-0000-0000-0000-000000000000 x-ms-ests-server: REDACTED x-ms-srs: REDACTED date: Sat, 31 Jan 2026 00:09:29 GMT content-type: application/json; charset=utf-8 expires: -1 content-security-policy-report-only: REDACTED set-cookie: REDACTED x-xss-protection: REDACTED pragma: no-cache content-length: 1717 p3p: REDACTED cache-control: no-store, no-cache x-content-type-options: REDACTED strict-transport-security: REDACTED  } }
2026-01-31T01:04:29.990787Z  INFO  typespec_client_core::http::policies::logging: ==> Request: url: https://login.microsoftonline.com/00000000-0000-0000-0000-000000000000/oauth2/v2.0/token, method: POST, headers: { user-agent: azsdk-rust-identity/0.30.0 (1.92.0; linux; x86_64) content-type: application/x-www-form-urlencoded x-ms-client-request-id: 00000000-0000-0000-0000-000000000000  }
2026-01-31T01:04:30.252971Z  INFO  typespec_client_core::http::policies::logging: <== Response: { url: https://login.microsoftonline.com/00000000-0000-0000-0000-000000000000/oauth2/v2.0/token, status: 200, headers: { x-ms-ests-server: REDACTED content-type: application/json; charset=utf-8 p3p: REDACTED pragma: no-cache x-content-type-options: REDACTED x-ms-srs: REDACTED expires: -1 date: Sat, 31 Jan 2026 01:04:30 GMT strict-transport-security: REDACTED x-xss-protection: REDACTED set-cookie: REDACTED content-security-policy-report-only: REDACTED x-ms-request-id: 00000000-0000-0000-0000-000000000000 content-length: 1727 cache-control: no-store, no-cache  } }
2026-01-31T01:59:29.956611Z  INFO  typespec_client_core::http::policies::logging: ==> Request: url: https://login.microsoftonline.com/00000000-0000-0000-0000-000000000000/oauth2/v2.0/token, method: POST, headers: { x-ms-client-request-id: 00000000-0000-0000-0000-000000000000 content-type: application/x-www-form-urlencoded user-agent: azsdk-rust-identity/0.30.0 (1.92.0; linux; x86_64)  }
2026-01-31T01:59:30.259192Z  INFO  typespec_client_core::http::policies::logging: <== Response: { url: https://login.microsoftonline.com/00000000-0000-0000-0000-000000000000/oauth2/v2.0/token, status: 200, headers: { cache-control: no-store, no-cache x-ms-request-id: 00000000-0000-0000-0000-000000000000 content-type: application/json; charset=utf-8 content-security-policy-report-only: REDACTED expires: -1 date: Sat, 31 Jan 2026 01:59:29 GMT pragma: no-cache x-content-type-options: REDACTED strict-transport-security: REDACTED x-xss-protection: REDACTED x-ms-srs: REDACTED set-cookie: REDACTED x-ms-ests-server: REDACTED content-length: 1717 p3p: REDACTED  } }
2026-01-31T02:54:30.952123Z  INFO  typespec_client_core::http::policies::logging: ==> Request: url: https://login.microsoftonline.com/00000000-0000-0000-0000-000000000000/oauth2/v2.0/token, method: POST, headers: { content-type: application/x-www-form-urlencoded x-ms-client-request-id: 00000000-0000-0000-0000-000000000000 user-agent: azsdk-rust-identity/0.30.0 (1.92.0; linux; x86_64)  }
2026-01-31T02:54:31.198919Z  INFO  typespec_client_core::http::policies::logging: <== Response: { url: https://login.microsoftonline.com/00000000-0000-0000-0000-000000000000/oauth2/v2.0/token, status: 200, headers: { set-cookie: REDACTED x-ms-request-id: 00000000-0000-0000-0000-000000000000 strict-transport-security: REDACTED content-type: application/json; charset=utf-8 pragma: no-cache x-ms-ests-server: REDACTED x-ms-srs: REDACTED x-xss-protection: REDACTED content-length: 1717 expires: -1 cache-control: no-store, no-cache date: Sat, 31 Jan 2026 02:54:30 GMT x-content-type-options: REDACTED p3p: REDACTED content-security-policy-report-only: REDACTED  } }
2026-01-31T03:49:30.952551Z  INFO  typespec_client_core::http::policies::logging: ==> Request: url: https://login.microsoftonline.com/00000000-0000-0000-0000-000000000000/oauth2/v2.0/token, method: POST, headers: { user-agent: azsdk-rust-identity/0.30.0 (1.92.0; linux; x86_64) content-type: application/x-www-form-urlencoded x-ms-client-request-id: 00000000-0000-0000-0000-000000000000  }
2026-01-31T03:49:31.215154Z  INFO  typespec_client_core::http::policies::logging: <== Response: { url: https://login.microsoftonline.com/00000000-0000-0000-0000-000000000000/oauth2/v2.0/token, status: 200, headers: { x-ms-ests-server: REDACTED x-ms-request-id: 00000000-0000-0000-0000-000000000000 content-length: 1727 x-ms-srs: REDACTED cache-control: no-store, no-cache x-xss-protection: REDACTED x-content-type-options: REDACTED content-security-policy-report-only: REDACTED pragma: no-cache content-type: application/json; charset=utf-8 set-cookie: REDACTED date: Sat, 31 Jan 2026 03:49:31 GMT strict-transport-security: REDACTED expires: -1 p3p: REDACTED  } }

Since azure_identity doesn't do much logging, these appear out of the blue; and apart from failures, these aren't very useful.

This PR downgrades these logs to debug, consistent with the Python SDK.

I did consider a more complete PR, and the Failed response case: and either holding off logging the Request (not ideal), or re-log the Request as info... but for every use-case I can think of, the only useful info is the Timestamp and X-MS-Request-ID headers for raising a support case, both which are both in the Response anyway.

@github-actions github-actions bot added Azure.Core The azure_core crate Community Contribution Community members are working on the issue customer-reported Issues that are reported by GitHub users external to the Azure organization. labels Jan 31, 2026
@github-actions
Copy link
Copy Markdown

Thank you for your contribution @jlaundry! We will review the pull request and get back to you soon.

@LarryOsterman
Copy link
Copy Markdown
Member

When using azure_identity, applications see Request and Response INFO log events as access tokens are refreshed, sometimes hourly(ish):

Since azure_identity doesn't do much logging, these appear out of the blue; and apart from failures, these aren't very useful.

This PR downgrades these logs to debug, consistent with the Python SDK.

I did consider a more complete PR, and the Failed response case: and either holding off logging the Request (not ideal), or re-log the Request as info... but for every use-case I can think of, the only useful info is the Timestamp and X-MS-Request-ID headers for raising a support case, both which are both in the Response anyway.

When I originally added the logging policy, I wanted the traces to be a higher visibility than the random noise of debugging so developers could see the HTTP operations without the debug spew from the service client.

But I do see your point.

One possible refinement (and possible feature creep) would be to make the debug level be configurable in the logging client options and then have identity use the debug logging level and other SDKs use Info. But that's probably overkill.

@jlaundry
Copy link
Copy Markdown
Contributor Author

jlaundry commented Feb 3, 2026

One possible refinement (and possible feature creep) would be to make the debug level be configurable in the logging client options and then have identity use the debug logging level and other SDKs use Info. But that's probably overkill.

It's valid. But other high-volume activity (i.e., regular polling of a Queue, pushing data to an Event Hub, sending traces to Log Analytics, etc.) may also need to be excluded, so we would probably end up the other way round, with Info as the option.

In most production deployment cases, unless there was a specific issue we were trying to diagnose, I would typically expect applications to run at Info level, and not see upstream API activity unless they ran with -v or -vv flags.

(I'm trying to think of counter examples, low-volume operations where you may want verbose logging to know exact timestamps of when something was done: KeyVault signing/decryption operations, database schema changes, maybe DNS changes... but in all those cases, I'd expect the application to be logging those events as well.)

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR reduces default log noise from typespec_client_core’s HTTP logging policy by downgrading routine request/response trace messages from INFO to DEBUG, which is particularly relevant for azure_identity token refresh traffic.

Changes:

  • Switch request logging from tracing::info! to tracing::debug!.
  • Switch successful response logging from tracing::info! to tracing::debug!.
  • Update tracing imports accordingly.
Comments suppressed due to low confidence (1)

sdk/core/typespec_client_core/src/http/policies/logging.rs:52

  • With the request log now at debug!, when next[0].send(...) returns Err the info-level logs no longer include the request method/headers (only the URL and error from the "<== Failed response" branch). This makes diagnosing transient transport/auth failures harder at the default info level. Consider either (a) logging the request at info only when the response is Err, or (b) including the request method (and optionally sanitized headers) in the existing info-level failed-response log message so failures still have enough context without reintroducing routine token-refresh noise.
        debug!(
            "==> Request: url: {}, method: {}, headers: {{ {} }}",
            request.url.sanitize(&self.allowed_query_params),
            request.method(),
            request.headers().sanitize(&self.allowed_headers)
        );

@LarryOsterman
Copy link
Copy Markdown
Member

/azp run rust - pullrequest

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@LarryOsterman
Copy link
Copy Markdown
Member

/checkenforcer evaluate

@LarryOsterman
Copy link
Copy Markdown
Member

/check-enforcer evaluate

@LarryOsterman
Copy link
Copy Markdown
Member

/check-enforcer help

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 7, 2026

For help using check enforcer, see https://aka.ms/azsdk/checkenforcer

Available commands:

  • /check-enforcer evaluate - Re-evaluate existing pipeline statuses for PR
  • /check-enforcer override - Ignore any pipeline missing or failed statuses for PR
  • /check-enforcer help - Add this comment

If you are initializing a new service, follow the new service docs. If no Azure Pipelines are desired, run /check-enforcer override.

@LarryOsterman
Copy link
Copy Markdown
Member

/check-enforcer evaluate

Signed-off-by: Jed Laundry <jlaundry@jlaundry.com>
@LarryOsterman LarryOsterman force-pushed the fix-typespec-http-logging-level branch from 0b1c414 to a4e5c24 Compare April 7, 2026 23:40
@LarryOsterman LarryOsterman enabled auto-merge (squash) April 7, 2026 23:58
@LarryOsterman LarryOsterman merged commit 66823f1 into Azure:main Apr 8, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Azure.Core The azure_core crate Community Contribution Community members are working on the issue customer-reported Issues that are reported by GitHub users external to the Azure organization.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants